import java.util.Scanner;

public class HJ2{
        public static void main(String[] args){
            //一个Scanner，读两行
            Scanner in = new Scanner(System.in);
            String str1 = in.nextLine();
            String str2 = in.nextLine();
            int str1Len = str1.length();
            int sum = 0;

            for(int i = 0; i < str1Len; i++){
                String str3 = str1.substring(i,i+1);
                //忽略大小写
                if(str2.equalsIgnoreCase(str3)){
                    sum +=1;
                }
            }

            System.out.println(sum);
        }
}
